<#import '/fed/demo/inc/macros.ftl' as macros />
<@macros.header 'upload'>
</@macros.header>

<#global demos = [
  {
    'n': 'image',
    'd': '\'\'',
    's': '图片上传（到图库）',
    'e': '',
    'c': ['
new ImageDialog({
  events: {
    all: function (e) {
      console.log(e.target.type, e.type, arguments);
    },
    // 处理完成
    complete: function (e, file) {
      console.log(\'COMPLETE\', file);
    }
  }
});']
  },
  {
    'n': 'image',
    'd': '\'\'',
    's': '图片上传（到专题）',
    'e': '',
    'c': ['
new ImageDialog({
  formData: {
    dir: \'somedir\'
  },
  process: false,
  uploadOptions: {
    url: \'topImageUpload\',
  },
  events: {
    all: function (e) {
      console.log(e.target.type, e.type, arguments);
    },
    // 处理完成
    complete: function (e, file) {
      console.log(\'COMPLETE\', file);
    }
  }
});']
  },
  {
    'n': 'file',
    'd': '\'\'',
    's': '文件上传',
    'e': '<div id="demo-container"></div>',
    'c': ['
new FileDialog({
  formData: {
    dir: \'somedir\'
  },
  events: {
    all: function (e) {
      console.log(e.target.type, e.type, arguments);
    },
    // 处理完成
    complete: function (e, file) {
      console.log(\'COMPLETE\', file);
    }
  }
});']
  }
]>

<@macros.body 'upload' 'upload'>
</@macros.body>

<@macros.footer>
  <script>
    seajs.use(['${appRoot}/common/upload/image/dialog', '${appRoot}/common/upload/file/dialog'], function (ImageDialog, FileDialog) {
      $('.demo > button').on('click', function () {
        new Function('ImageDialog', 'FileDialog', this.nextElementSibling.textContent)(ImageDialog, FileDialog);
      }).eq(0).trigger('click')/*.remove()*/;
    });
  </script>
</@macros.footer>